#pragma once 


class CNetLocker
{
public:
	CNetLocker()	{ InitializeCriticalSection(&m_cs);}
	~CNetLocker()	{ DeleteCriticalSection(&m_cs);}
	void Lock()	    { EnterCriticalSection(&m_cs);}
	void Unlock()	{ LeaveCriticalSection(&m_cs);}
private:
	CRITICAL_SECTION    m_cs;
};

class CNetAutoLock
{
public:
	CNetAutoLock(CNetLocker *pCs):m_pCs(pCs)		{ if( pCs != NULL ) pCs->Lock();}
	~CNetAutoLock()									{ if( m_pCs != NULL ) m_pCs->Unlock();}
private:
	CNetLocker	*m_pCs;
};
